//
//  ReweetStatusView.m
//  SinaWebo
//
//  Created by 亦心 on 15/4/2.
//  Copyright (c) 2015年 亦心. All rights reserved.
//

#import "ReweetStatusView.h"
#import "EmotionTool.h"
#import "PhotosView.h"
#import "StatusFrame.h"
#import "CardView.h"
#import "Status.h"
#import "User.h"

@interface ReweetStatusView ()
/** 被转发微博的正文\内容 */
@property (nonatomic, weak) UILabel *retweetContentLabel;
/** 被转发微博的配图 */
@property (nonatomic, weak) PhotosView *retweetPhotoView;
/** 卡片 */
@property (weak, nonatomic) CardView *cardView;
@end
@implementation ReweetStatusView

- (instancetype)initWithCoder:(NSCoder *)coder{
    self=[super initWithCoder:coder];
    if (self) {
        [self initView];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame{
    self=[super initWithFrame:frame];
    if (self) {
        [self initView];
    }
    return self;
}

-(void)initView{
    self.userInteractionEnabled=YES;
    //设置背景图片
    self.backgroundColor = MyColor(245, 245, 245);
    
    /** 被转发微博的正文\内容 */
    UILabel *retweetContentLabel=[[UILabel alloc] init];
    retweetContentLabel.font = StatusFrameRewTextLabelFont;
    retweetContentLabel.textColor = MyColor(80, 80, 80);
    retweetContentLabel.numberOfLines = 0;
    self.retweetContentLabel=retweetContentLabel;
    [self addSubview:retweetContentLabel];
    
    /** 被转发微博的配图 */
    PhotosView *retweetPhotoView=[[PhotosView alloc]init];
    self.retweetPhotoView=retweetPhotoView;
    [self addSubview:retweetPhotoView];
    
    /** 卡片 */
    CardView *cardView = [[CardView alloc] init];
    cardView.hidden = YES;
    [self addSubview:cardView];
    self.cardView = cardView;
    
}

-(void)setStatusFrame:(StatusFrame *)statusFrame{
    _statusFrame=statusFrame;
    Status *retweetStatus=statusFrame.status.retweeted_status;
    /** 被转发微博的正文\内容 */
    self.retweetContentLabel.frame=self.statusFrame.retweetContentLabelF;
    self.retweetContentLabel.attributedText = _statusFrame.retweetedText;
    if (retweetStatus.pic_ids.count) {
        /** 被转发微博的配图 */
        self.retweetPhotoView.hidden=NO;
        self.retweetPhotoView.frame=self.statusFrame.retweetPhotoViewF;
        [self.retweetPhotoView setPhotos:retweetStatus.pics];
    }else{
        self.retweetPhotoView.hidden=YES;
    }
    /** 卡片 */
    if (statusFrame.status.page_info && retweetStatus.pics.count == 0) {
        self.cardView.hidden = NO;
        self.cardView.frame = _statusFrame.retpageInfoViewF;
        self.cardView.pageInfo = statusFrame.status.page_info;
    }else{
        self.cardView.hidden = YES;
    }
}

- (void)stopVideo{
    [_cardView stopVideo];
}

- (void)playVideo{
    [_cardView playVideo];
}
@end
